package com.cg.resolvers;

import com.cg.entities.Address;
import com.cg.entities.User;
import com.cg.mapper.AddressMapper;
import com.netflix.graphql.dgs.DgsComponent;
import com.netflix.graphql.dgs.DgsData;
import com.netflix.graphql.dgs.DgsDataFetchingEnvironment;
import com.netflix.graphql.dgs.DgsSubscription;
import lombok.RequiredArgsConstructor;
import org.reactivestreams.Publisher;

import java.util.List;
import java.util.concurrent.Flow;

/**
 * @author cheyinbo
 * @description TODO
 * @date 2021/6/24 17:19
 */
@DgsComponent
@RequiredArgsConstructor
public class AddressResolver {

    private final AddressMapper addressMapper;

    @DgsData(parentType ="User",field ="homeaddress" )
    public List<Address> listAddressByUid(DgsDataFetchingEnvironment dfe){
        User context = dfe.getSource();
        return addressMapper.listAddressByUid(context.getId());
    }

}
